package org.zoomdev.zoom.dao.adapters.parameter;

import org.zoomdev.zoom.dao.adapters.ParameterAdapter;

import java.sql.PreparedStatement;
import java.sql.SQLException;
import java.time.LocalDateTime;

// Java 8 LocalDateTime类型适配器
public class LocalDateTimeParameterAdapter implements ParameterAdapter<LocalDateTime> {

    @Override
    public void setNonnullParameter(PreparedStatement ps, int index, LocalDateTime data) throws SQLException {
        LocalDateTime truncated = data.withNano(0);
        ps.setObject(index, truncated);
    }
}
